import Vue from 'vue'
import VueRouter from 'vue-router'
import OrderList from '../views/OrderList.vue'
import OrderDetail from '../views/OrderDetail.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/login/Login.vue')
  },
  {
    path: '/',
    redirect: '/login',
    component: () => import('../views/Layout.vue'),
    children: [
      {
        path: 'products',
        name: 'Products',
        component: () => import('../views/products/Index.vue'),
        meta: { roles: ['admin', 'manager', 'stockkeeper'] }
      },
      {
        path: 'categories',
        name: 'Categories',
        component: () => import('../views/categories/Index.vue'),
        meta: { roles: ['admin', 'manager', 'stockkeeper'] }
      },
      {
        path: 'inventory',
        name: 'Inventory',
        component: () => import('../views/inventory/Index.vue'),
        meta: { roles: ['admin', 'manager', 'warehouse'] }
      },
      {
        path: 'orders',
        name: 'OrderList',
        component: OrderList,
        meta: { roles: ['admin', 'manager', 'stockkeeper'] }
      },
      {
        path: 'orders/:orderNo',
        name: 'OrderDetail',
        component: OrderDetail,
        meta: { roles: ['admin', 'manager', 'stockkeeper'] }
      },
      {
        path: 'statistics',
        name: 'Statistics',
        component: () => import('../views/statistics/Index.vue'),
        meta: { roles: ['admin', 'manager'] }
      },
      {
        path: 'employees',
        name: 'Employees',
        component: () => import('../views/employees/Index.vue'),
        meta: { roles: ['admin', 'manager'] }
      },
      {
        path: 'roles',
        name: 'Roles',
        component: () => import('../views/roles/Index.vue'),
        meta: { roles: ['admin'] }
      },
      {
        path: 'shipping-addresses',
        name: 'ShippingAddresses',
        component: () => import('@/views/ShippingAddress.vue'),
        meta: { roles: ['admin', 'manager', 'stockkeeper'] }
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router 